ABC357F - Two Sequence Queries